# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Fabio Ribeiro <fabiorphp@gmail.com>
pkgname=php7-pecl-solr
_pkgreal=solr
pkgver=2.5.1
pkgrel=0
pkgdesc="Apache SOLR extension for PHP"
url="https://pecl.php.net/package/solr"
arch="all"
license="PHP-3.01"
depends="php7-json"
makedepends="php7-dev curl-dev libxml2-dev"
source="$pkgname-$pkgver.tgz::https://pecl.php.net/get/$_pkgreal-$pkgver.tgz
	fix-tests.patch"
builddir="$srcdir"/$_pkgreal-$pkgver
provides="php7-solr=$pkgver-r$pkgrel" # for backward compatibility
replaces="php7-solr" # for backward compatibility

build() {
	phpize7
	./configure --prefix=/usr --with-php-config=php-config7
	make
}

check() {
	php7 -d extension=modules/$_pkgreal.so --ri $_pkgreal
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 SKIP_ONLINE_TESTS=1 test \
		TESTS='--show-diff' \
		PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=/usr/lib/php7/modules/json.so \
		-d extension=modules/$_pkgreal.so"
}

package() {
	make INSTALL_ROOT="$pkgdir"/ install
	local _confdir=/etc/php7/conf.d
	install -d "$pkgdir"$_confdir
	echo "extension=$_pkgreal.so" > "$pkgdir"$_confdir/40_$_pkgreal.ini
}

sha512sums="b02711989455f3839e65835808dae66fdce6abfd85fe2cb3d46c4177deb2170b5993ee0c94177c880d3defac2d2c502b43d768b590b7180b5c38ab063f55bdf3  php7-pecl-solr-2.5.1.tgz
553503d194c8c8c4db065a4c21136e51d4ba8bb9a74327d312a6506e12d91b4d2b72c5082741e961df7f3852fecf2374333c8f00a173ca2e6e7e6f1049ecf6cb  fix-tests.patch"
